<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\SystemSetting;

class SystemSettingSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $settings = [
            // 基础设置
            [
                'group' => 'basic',
                'key' => 'site_name',
                'value' => '橙科技',
                'type' => 'text',
                'label' => '网站名称',
                'description' => '显示在网站标题和页脚，留空则使用配置文件中的 APP_NAME',
                'is_public' => true,
                'sort_order' => 1,
            ],
            [
                'group' => 'basic',
                'key' => 'contact_email',
                'value' => 'support@orangetech.com',
                'type' => 'text',
                'label' => '联系邮箱',
                'description' => '用于接收客户咨询和系统通知',
                'is_public' => true,
                'sort_order' => 2,
            ],
            [
                'group' => 'basic',
                'key' => 'contact_phone',
                'value' => '400-668-8866',
                'type' => 'text',
                'label' => '联系电话',
                'description' => '客服电话号码',
                'is_public' => true,
                'sort_order' => 3,
            ],
            [
                'group' => 'basic',
                'key' => 'about_us',
                'value' => 'Orange Tech 诞生于对简约设计和极致体验的追求。我们相信，科技产品不仅要功能强大，更要设计优雅、使用简单。就像新鲜的橙子一样，我们的产品为用户带来清新、活力的科技体验。',
                'type' => 'textarea',
                'label' => '关于我们',
                'description' => '公司简介',
                'is_public' => true,
                'sort_order' => 4,
            ],
            [
                'group' => 'basic',
                'key' => 'site_logo',
                'value' => '/images/logo.svg',
                'type' => 'file',
                'label' => '网站 Logo',
                'description' => '网站 Logo 图片，建议尺寸 200x60px，支持 SVG、PNG、JPG 格式',
                'is_public' => true,
                'sort_order' => 5,
            ],
            [
                'group' => 'basic',
                'key' => 'site_favicon',
                'value' => '/favicon.svg',
                'type' => 'file',
                'label' => '网站图标',
                'description' => '浏览器标签页图标，建议尺寸 32x32px，支持 SVG、ICO 格式',
                'is_public' => true,
                'sort_order' => 6,
            ],

            // 商城设置
            [
                'group' => 'shop',
                'key' => 'price_decimal_places',
                'value' => '2',
                'type' => 'number',
                'label' => '价格小数位数',
                'description' => '商品价格显示的小数位数',
                'is_public' => true,
                'sort_order' => 1,
            ],
            [
                'group' => 'shop',
                'key' => 'default_shipping_fee',
                'value' => '50',
                'type' => 'number',
                'label' => '默认运费',
                'description' => '默认配送费用（元）',
                'is_public' => true,
                'sort_order' => 2,
            ],
            [
                'group' => 'shop',
                'key' => 'free_shipping_threshold',
                'value' => '1000',
                'type' => 'number',
                'label' => '包邮门槛',
                'description' => '订单金额达到此金额免运费（元）',
                'is_public' => true,
                'sort_order' => 3,
            ],

            // 物流配送设置
            [
                'group' => 'shipping',
                'key' => 'default_shipping_time',
                'value' => '3-5',
                'type' => 'text',
                'label' => '默认配送时间',
                'description' => '默认配送时间（天），如：3-5',
                'is_public' => true,
                'sort_order' => 1,
            ],
            [
                'group' => 'shipping',
                'key' => 'shipping_note',
                'value' => '我们将在1-2个工作日内发货，节假日顺延',
                'type' => 'textarea',
                'label' => '配送说明',
                'description' => '配送相关说明文字',
                'is_public' => true,
                'sort_order' => 2,
            ],

            // 售后设置
            [
                'group' => '售后设置',
                'key' => 'refund_period_days',
                'value' => '7',
                'type' => 'number',
                'label' => '售后申请期限（天）',
                'description' => '用户收货后可申请售后的天数',
                'is_public' => true,
                'sort_order' => 1,
            ],
            [
                'group' => '售后设置',
                'key' => 'auto_confirm_days',
                'value' => '7',
                'type' => 'number',
                'label' => '自动确认收货天数',
                'description' => '发货后多少天未确认自动确认收货',
                'is_public' => true,
                'sort_order' => 2,
            ],
            [
                'group' => '售后设置',
                'key' => 'exchange_delivery_timeout_days',
                'value' => '7',
                'type' => 'number',
                'label' => '换货送达超时天数',
                'description' => '换货商品寄出后多少天自动确认送达',
                'is_public' => true,
                'sort_order' => 3,
            ],

            // SEO 设置
            [
                'group' => 'seo',
                'key' => 'seo_title',
                'value' => '橙科技',
                'type' => 'text',
                'label' => 'SEO 标题',
                'description' => '网站SEO标题，留空则使用网站名称',
                'is_public' => true,
                'sort_order' => 1,
            ],
            [
                'group' => 'seo',
                'key' => 'seo_keywords',
                'value' => 'Orange Tech, 橙科技, Orange Phone, Orange Pad, Orange Book, 科技产品, 简约设计',
                'type' => 'text',
                'label' => 'SEO 关键词',
                'description' => '网站关键词，用逗号分隔',
                'is_public' => true,
                'sort_order' => 2,
            ],
            [
                'group' => 'seo',
                'key' => 'seo_description',
                'value' => 'Orange Tech - 新鲜科技，触手可及。提供 Orange Phone、Orange Pad、Orange Book 等全系列科技产品，简约设计，极致体验。',
                'type' => 'textarea',
                'label' => 'SEO 描述',
                'description' => '网站描述',
                'is_public' => true,
                'sort_order' => 3,
            ],
        ];

        foreach ($settings as $setting) {
            SystemSetting::updateOrCreate(
                ['key' => $setting['key']],
                $setting
            );
        }

        $this->command->info('✅ 系统设置数据填充完成！');
    }
}
